<template>
  <div>
    <!-- 车辆登记表单区域 -->
    <div class="list">
      <h2>车辆登记</h2>
      <el-form label-width="110px" :rules="listRules" :model="list">
        <el-row>
          <el-col :span="12">
            <el-form-item label="车牌号" prop="plate">
              <el-input v-model="list.plate"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车辆颜色" prop="color">
              <el-input v-model="list.color"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="发动机号" prop="engineNumber">
              <el-input v-model="list.engineNumber"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="车架号" prop="VIN">
              <el-input v-model="list.VIN"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="出厂日期" prop="birth">
              <el-date-picker
                  v-model="list.birth"
                  type="date"
                  placeholder="选择日期" style="width: 250px;">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="年检到期" prop="expire">
              <el-date-picker
                  v-model="list.expire"
                  type="date"
                  placeholder="选择日期" style="width: 250px;">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="行程里数" prop="tripMileage">
              <el-input v-model="list.tripMileage"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="结构特点" prop="features">
              <el-radio v-model="list.features" label="1">自动挡</el-radio>
              <el-radio v-model="list.features" label="2">手动挡</el-radio>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 图片区域 -->
    <div class="pic">
      <span class="demonstration">车辆图片</span>
      <el-carousel height="180px" style="border-radius: 25px">
        <el-carousel-item v-for="item in 4" :key="item">
          <h3 class="small">{{ item }}</h3>
        </el-carousel-item>
      </el-carousel>
    </div>
    <div class="a">
      <el-button type="primary" @click="add">确定登记</el-button>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      //司机登记表单的数据绑定
      list: {
        plate: '',
        color: '',
        engineNumber: '',
        VIN: '',
        birth: '',
        expire: '',
        tripMileage: '',
        features: ''
      },
      //照片的数据绑定
      imageUrl: '',
      //登记表单的验证规则对象
      listRules: {
        //验证车牌号
        plate: [
          {required: true, message: '请输入车牌号', trigger: 'blur'},
          {min: 7, max: 7, message: 'c车牌号应为7位数哦', trigger: 'blur'}
        ],
        //验证颜色是否为空
        color: [
          {required: true, message: '请输入车辆颜色', trigger: 'blur'},
        ],
        //验证发动机号是否为空
        engineNumber: [
          {required: true, message: '请输入发动机号', trigger: 'blur'}
        ],
        //验证车架号是否为空
        VIN: [
          {required: true, message: '请输入车架号', trigger: 'blur'}
        ],
        //验证出厂日期是否为空
        birth: [
          {required: true, message: '请输入车辆出厂日期', trigger: 'blur'}
        ],
        //验证年检日期是否为空
        expire: [
          {required: true, message: '请输入年检到期', trigger: 'blur'}
        ],
        //验证行程里数是否为空
        tripMileage: [
          {required: true, message: '请输入行程里数', trigger: 'blur'}
        ],
        //验证结构特点是否为空
        features: [
          {required: true, message: '请选择结构特点', trigger: 'blur'}
        ]
      }
    }
  },
  methods: {
    add() {
      if (this.$data.list.plate
          && this.$data.list.color
          && this.$data.list.engineNumber
          && this.$data.list.VIN
          && this.$data.list.birth
          && this.$data.list.expire
          && this.$data.list.tripMileage
          && this.$data.list.features !== '') {
        return this.$message.success('登记成功')
      }
      this.$message.error('登记失败！检查你还有什么没有填哦！')
    }
  }
}
</script>

<style Lang="less" scoped>
.list {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  height: 400px;

}

.el-input {
  width: 250px;
}

.el-checkbox {
  padding: 0;
}

h2 {
  text-align: center;
  padding-bottom: 25px;
  color: #ffffff;
}

.checkbox {
  width: 280px;
}

.pic {
  position: absolute;
  left: 35%;
  top: 70%;
  height: 300px;
  width: 500px;
  text-align: center;
}

span {
  color: #fff;
  font-size: 20px;
  padding-bottom: 5px;
}

.el-carousel__item h3 {
  color: #475669;
  font-size: 14px;
  opacity: 0.75;
  line-height: 150px;
  margin: 0;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n+1) {
  background-color: #d3dce6;
}

.a {
  position: absolute;
  right: 30%;
  top: 110%;
  height: 150px;
}
</style>
